package com.txy.springcloud.controller;

import com.txy.springcloud.util.SendEmail_text;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/email")
public class EmailController {
    @Value("${email.sender.username}")
    private String username;

    @Value("${email.sender.password")
    private String password;

    @RequestMapping("/{email}/{code}")
    public boolean sendCode(@PathVariable("email") String email, @PathVariable("code") String code) {
        try {
            SendEmail_text.send(email, "验证码", code);
            return true;
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
    }
}
